<template>
<div>
    <el-form :model="inputForm" ref="inputForm" v-loading="loading"   :disabled="formReadOnly"
             label-width="120px">
      <el-row  :gutter="15">
        <el-col :span="24">
            <el-form-item label="产线" prop="basicdataLine"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataLine" placeholder="请填写产线"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="作业区" prop="basicdataWorkRegion"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataWorkRegion" placeholder="请填写作业区"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="主体设备" prop="basicdataMainEquipment"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataMainEquipment" placeholder="请填写主体设备"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="部件" prop="basicdataPart"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataPart" placeholder="请填写部件"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="零件" prop="basicdataConponent"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataConponent" placeholder="请填写零件"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="油品型号" prop="basicdataOilType"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataOilType" placeholder="请填写油品型号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="检验周期" prop="basicdataCheckPeriod"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCheckPeriod" placeholder="请填写检验周期"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="清洁度" prop="basicdataCleanlness"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCleanlness" placeholder="请填写清洁度"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="运动粘度" prop="basicdataSportViscosity"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataSportViscosity" placeholder="请填写运动粘度"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="酸值" prop="basicdataAuidValue"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataAuidValue" placeholder="请填写酸值"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="水分" prop="basicdataWater"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataWater" placeholder="请填写水分"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="抗乳化" prop="basicdataRepelCreaming"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataRepelCreaming" placeholder="请填写抗乳化"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="凝点" prop="basicdataCondensationPoint"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCondensationPoint" placeholder="请填写凝点"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="倾点" prop="basicdataPourPoint"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataPourPoint" placeholder="请填写倾点"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="责任人" prop="basicdataDutyPeople.id"
                :rules="[
                 ]">
                <user-select :limit='1' :value="inputForm.basicdataDutyPeople.id" @getValue='(value) => {inputForm.basicdataDutyPeople.id=value}'></user-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="检验人" prop="basicdataCheckMan.id"
                :rules="[
                 ]">
                <user-select :limit='1' :value="inputForm.basicdataCheckMan.id" @getValue='(value) => {inputForm.basicdataCheckMan.id=value}'></user-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="父类" prop="partDeviceId"
                :rules="[
                 ]">
              <el-input v-model="inputForm.partDeviceId" placeholder="请填写父类"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="用户" prop="userId"
                :rules="[
                 ]">
              <el-input v-model="inputForm.userId" placeholder="请填写用户"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="零件名称" prop="unitName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.unitName" placeholder="请填写零件名称"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="油检起始时间" prop="basicdataTime"
                :rules="[
                 ]">
                <el-date-picker
                      v-model="inputForm.basicdataTime"
                      type="datetime"
                      style="width: 100%;"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间">
                    </el-date-picker>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="备注信息" prop="remarks"
                :rules="[
                 ]">
          <el-input type="textarea" v-model="inputForm.remarks" placeholder="请填写备注信息"     ></el-input>
           </el-form-item>
        </el-col>
        </el-row>
    </el-form>
</div>
</template>

<script>
  import UserSelect from '@/components/userSelect'
  export default {
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        inputForm: {
          id: '',
          basicdataLine: '',
          basicdataWorkRegion: '',
          basicdataMainEquipment: '',
          basicdataPart: '',
          basicdataConponent: '',
          basicdataOilType: '',
          basicdataCheckPeriod: '',
          basicdataCleanlness: '',
          basicdataSportViscosity: '',
          basicdataAuidValue: '',
          basicdataWater: '',
          basicdataRepelCreaming: '',
          basicdataCondensationPoint: '',
          basicdataPourPoint: '',
          basicdataDutyPeople: {
            id: ''
          },
          basicdataCheckMan: {
            id: ''
          },
          partDeviceId: '',
          userId: '',
          unitName: '',
          basicdataTime: '',
          remarks: ''
        }
      }
    },
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      }
    },
    components: {
      UserSelect
    },
    watch: {
      'businessId': {
        handler (newVal) {
          if (this.businessId) {
            this.init(this.businessId)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        },
        immediate: true,
        deep: false
      }
    },
    methods: {
      init (id) {
        if (id) {
          this.loading = true
          this.inputForm.id = id
          this.$nextTick(() => {
            this.$refs.inputForm.resetFields()
            this.$http({
              url: `/check/standardoil/checkStandardOil/queryById?id=${this.inputForm.id}`,
              method: 'get'
            }).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data.checkStandardOil)
              this.loading = false
            })
          })
        }
      },
      // 表单提交
      saveForm (callback) {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$http({
              url: `/check/standardoil/checkStandardOil/save`,
              method: 'post',
              data: this.inputForm
            }).then(({data}) => {
              if (data && data.success) {
                callback(data.businessTable, data.businessId)
              }
            })
          }
        })
      }
    }
  }
</script>